﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.Common;

using Husb.Data;
using Husb.DataUtil;
using Microsoft.Practices.EnterpriseLibrary.Data;

using CentralOffice.PublicAffair.Data;

using FavoriteTable = CentralOffice.PublicAffair.Data.FavoriteDataSet.FavoriteDataTable;
using FavoriteRow = CentralOffice.PublicAffair.Data.FavoriteDataSet.FavoriteRow;


namespace CentralOffice.PublicAffair.DataAccess
{
    public class FavoriteAdapter : DataAccessAdapter<FavoriteDataSet, FavoriteTable, FavoriteRow>
    {

        public FavoriteAdapter()
        {
            this.TableName = "Favorite";

            GetAllStoredProc = "PublicAffairs.Favorite_SelectFavoritesAll";
            InsertStoredProc = "PublicAffairs.Favorite_InsertFavorite";
            UpdateStoredProc = "PublicAffairs.Favorite_UpdateFavorite";
            DeleteStoredProc = "PublicAffairs.Favorite_DeleteFavorite";

            GetByIdStoredProc = "PublicAffairs.Favorite_SelectFavorite";
            GetByNameStoredProc   = "";
            GetPagedStoredProc = "PublicAffairs.Favorite_SelectFavoritesPaged";
            GetRowCountStoredProc = "PublicAffairs.Favorite_SelectFavoritesRowCount";
            FindStoredProc = "PublicAffairs.Favorite_SelectFavoritesDynamic";

            LogicalDeleteStoredProc = "PublicAffairs.Favorite_DeleteFavoriteLogical";
        }

        protected override void PopulateInsertParameters(Database db, DbCommand cmd)
        {
            //db.AddInParameter(cmd, "Id", DbType.Guid, "Id", DataRowVersion.Current);
			db.AddInParameter(cmd, "Id", DbType.Guid, "Id", DataRowVersion.Current);
			db.AddInParameter(cmd, "Link", DbType.AnsiString, "Link", DataRowVersion.Current);
			db.AddInParameter(cmd, "Name", DbType.String, "Name", DataRowVersion.Current);
			db.AddInParameter(cmd, "Remark", DbType.String, "Remark", DataRowVersion.Current);
			db.AddInParameter(cmd, "IsDeleted", DbType.Boolean, "IsDeleted", DataRowVersion.Current);
			db.AddInParameter(cmd, "IsActive", DbType.Boolean, "IsActive", DataRowVersion.Current);
			db.AddInParameter(cmd, "CreatedTime", DbType.DateTime, "CreatedTime", DataRowVersion.Current);
			db.AddInParameter(cmd, "CreatedBy", DbType.Guid, "CreatedBy", DataRowVersion.Current);
			db.AddInParameter(cmd, "ModifiedTime", DbType.DateTime, "ModifiedTime", DataRowVersion.Current);
			db.AddInParameter(cmd, "LastModifiedBy", DbType.Guid, "LastModifiedBy", DataRowVersion.Current);
			db.AddInParameter(cmd, "Version", DbType.Int32, "Version", DataRowVersion.Current);
			db.AddInParameter(cmd, "Description", DbType.AnsiString, "Description", DataRowVersion.Current);
        }
    }
}
